﻿#include "cprogressdlg.h"
#include <QApplication>
#include "mytestsignal.h"//自测发送信号的类
#include <unistd.h>
#include <QThread>

#if defined(_MSC_VER) && (_MSC_VER >= 1600)
# pragma execution_character_set("utf-8")
#endif

class MyThread : public QThread
{
public:
    MyThread(mytestsignal *test)
    {
        mytest = test;
    }
protected:
    void run() // 线程入口函数
    {
        for(int j=1;j<=1;j++)// 步骤step
        {
            for(int i=1; i<=100; i++)//目前已完成curr
            {
                mytest->testsignal2(j,100,i);
                mytest->testsignal1("eg:计算构建坐标范围...");  //mytest指定三个信号参数
                mytest->testsignal3("eg:3753551,8bf14963_a36b...");
                _sleep(30);
            }
        }
        return;
    }
private:
    mytestsignal *mytest;//声明一个测试信号的指针(由它来指定信号参数)
};


int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QStringList temp;
    temp.append("查找相关构件");//此处和总步骤保持一致
//    temp.append("分析模型");
//    temp.append("计算");
//    temp.append("未知任务");
//    temp.append("可扩展性");
    CProgressDlg *w=new CProgressDlg(temp);//传入Qstringlist;

    w->show();
    mytestsignal test;//创建sender
    w->m_BaseTime = QTime::currentTime();//计时器的基准时间

    QObject::connect(&test, &mytestsignal::testsignal2,w, &CProgressDlg::ProgressBar);
    QObject::connect(&test, &mytestsignal::testsignal2,w, &CProgressDlg::ProgressTask);
    QObject::connect(&test,&mytestsignal::testsignal2,w,&CProgressDlg::SetData1);
    QObject::connect(&test,&mytestsignal::testsignal2,w,&CProgressDlg::SetData2);
    QObject::connect(&test,&mytestsignal::testsignal1,w,&CProgressDlg::SetData3);
    QObject::connect(&test,&mytestsignal::testsignal3,w,&CProgressDlg::SetData4);

    MyThread *t = new MyThread(&test); // 创建子线程
    t->setObjectName("t");
    t->start(); // 启动子线程
    return a.exec();
}
